/* *****************************************************************
 *
 * Download latest Blinker library here:
 * https://github.com/blinker-iot/blinker-library/archive/master.zip
 * 
 * 
 * Blinker is a cross-hardware, cross-platform solution for the IoT. 
 * It provides APP, device and server support, 
 * and uses public cloud services for data transmission and storage.
 * It can be used in smart home, data monitoring and other fields 
 * to help users build Internet of Things projects better and faster.
 * 
 * Make sure installed 2.7.4 or later ESP8266/Arduino package,
 * if use ESP8266 with Blinker.
 * https://github.com/esp8266/Arduino/releases
 * 
 * Make sure installed 1.0.5 or later ESP32/Arduino package,
 * if use ESP32 with Blinker.
 * https://github.com/espressif/arduino-esp32/releases
 * 
 * Docs: https://diandeng.tech/doc
 *       
 * 
 * *****************************************************************
 * 
 * Blinker 库下载地址:
 * https://github.com/blinker-iot/blinker-library/archive/master.zip
 * 
 * Blinker 是一套跨硬件、跨平台的物联网解决方案，提供APP端、设备端、
 * 服务器端支持，使用公有云服务进行数据传输存储。可用于智能家居、
 * 数据监测等领域，可以帮助用户更好更快地搭建物联网项目。
 * 
 * 如果使用 ESP8266 接入 Blinker,
 * 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
 * https://github.com/esp8266/Arduino/releases
 * 
 * 如果使用 ESP32 接入 Blinker,
 * 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
 * https://github.com/espressif/arduino-esp32/releases
 * 
 * 文档: https://diandeng.tech/doc
 *       
 * 
 * *****************************************************************/

#if 0
#define BLINKER_WIFI
#define BLINKER_ALIGENIE_AIRCONDITION

#include <Blinker.h>
#include <Arduino.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp>

char auth[] = "524d601fad41";
char ssid[] = "JJYONG";
char pswd[] = "jjyong666";

bool oState = false;
bool hsState = false;
bool vsState = false;
String setLevel = "auto";
uint8_t setTemp = 24;

void aligenieTemp(uint8_t temp)
{
    BLINKER_LOG("need set temp: ", temp);
    if (setTemp < temp)
    {
        uint32_t tRawData_1 = 0x7C3 + ((temp - 8) * 0x800);
        uint32_t tRawData_4 = 2 + ((temp - 3) * 8);
        uint32_t tRawData[]={tRawData_1, 0x200020, 0x2000, tRawData_4};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    else
    {
        uint32_t tRawData_1 = 0x7C3 + ((temp - 8) * 0x800);
        uint32_t tRawData_4 = 2 + ((temp - 3) * 8) + 1;
        uint32_t tRawData[]={tRawData_1, 0x200020, 0x1002000, tRawData_4};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    setTemp = temp;

    BlinkerAliGenie.temp(temp);
    BlinkerAliGenie.print();
}

void aligenieRelativeTemp(int relTemp)
{
    BLINKER_LOG("need set temp: ", relTemp);

    setTemp = setTemp + relTemp;

    BlinkerAliGenie.temp(setTemp);
    BlinkerAliGenie.print();
}

void aligenieLevel(const String & level)
{
    BLINKER_LOG("need set level: ", level);
    // auto	自动风
    // low	低风
    // medium	中风
    // high	高风

    setLevel = level;

    BlinkerAliGenie.level(level);
    BlinkerAliGenie.print();
}

void aligenieHSwingState(const String & state)
{
    BLINKER_LOG("need set HSwing state: ", state);
    // horizontal-swing

    if (state == BLINKER_CMD_ON) {
        uint32_t tRawData[]={0xC3, 0xA0, 0x3002000, 0x86};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4550, 600, 1700, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);

        BlinkerAliGenie.hswing("on");
        BlinkerAliGenie.print();

        hsState = true;
    }
    else if (state == BLINKER_CMD_OFF) {
        uint32_t tRawData[]={0xE007C3, 0xA0, 0x3002000, 0x6D};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);

        BlinkerAliGenie.hswing("off");
        BlinkerAliGenie.print();

        hsState = false;
    }
}

void aligenieVSwingState(const String & state)
{
    BLINKER_LOG("need set VSwing state: ", state);
    // vertical-swing

    if (state == BLINKER_CMD_ON) {
        uint32_t tRawData[]={0xE000C3, 0xA0, 0x2002000, 0x65};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 650, 1650, 650, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);

        BlinkerAliGenie.vswing("on");
        BlinkerAliGenie.print();

        vsState = true;
    }
    else if (state == BLINKER_CMD_OFF) {
        uint32_t tRawData[]={0x7C3, 0xA0, 0x2002000, 0x8C};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1700, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);

        BlinkerAliGenie.vswing("off");
        BlinkerAliGenie.print();

        vsState = false;
    }
}

void aligenieMode(const String & mode)
{
    BLINKER_LOG("need set mode: ", mode);
    if (mode.compareTo("auto") == 0)
    {
        uint32_t tRawData[]={0xE007C3, 0xA0, 0x6002000, 0x70};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    else if(mode.compareTo("cold") == 0)
    {
        uint32_t tRawData[]={0x7FC3, 0x200020, 0x6002000, 0xA8};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    else if(mode.compareTo("heat") == 0)
    {
        uint32_t tRawData[]={0xE0B0C3, 0x8000A0, 0x6003000, 0xA9};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    else if(mode.compareTo("dehumidification") == 0)
    {
        uint32_t tRawData[]={0xE05FC3, 0x400060, 0x6002000, 0xC8};
        IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4500, 600, 1650, 600, 500, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);  
    }
    else if(mode.compareTo("ventilate") == 0)
    {
        uint32_t tRawData[]={0xE007C3, 0xC00020, 0x6002000, 0xB0};
        IrSender.sendPulseDistanceWidthFromArray(38, 9100, 4450, 600, 1650, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    }
    BlinkerAliGenie.mode(mode);
    BlinkerAliGenie.print();
}

void aligeniePowerState(const String & state)
{
    BLINKER_LOG("need set power state: ", state);

    if (state == BLINKER_CMD_ON) {
        uint32_t tRawData[]={0xE007C3, 0xA0, 0x5002000, 0x6F};
        IrSender.sendPulseDistanceWidthFromArray(38, 9000, 4550, 600, 1700, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
        BlinkerAliGenie.powerState("on");
        BlinkerAliGenie.print();

        oState = true;
    }
    else if (state == BLINKER_CMD_OFF) {
        uint32_t tRawData[]={0xE007C3, 0xA0, 0x5000000, 0x4F};
        IrSender.sendPulseDistanceWidthFromArray(38, 9000, 4550, 600, 1700, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
        BlinkerAliGenie.powerState("off");
        BlinkerAliGenie.print();

        oState = false;
    }
}

void aligenieQuery(int32_t queryCode)
{
    BLINKER_LOG("AliGenie Query codes: ", queryCode);

    switch (queryCode)
    {
        case BLINKER_CMD_QUERY_ALL_NUMBER :
            BLINKER_LOG("AliGenie Query All");
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.hswing(hsState ? "on" : "off");
            BlinkerAliGenie.vswing(vsState ? "on" : "off");
            BlinkerAliGenie.level(setLevel);
            BlinkerAliGenie.mode("quietWind");
            BlinkerAliGenie.temp(setTemp);
            BlinkerAliGenie.print();
            break;
        case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
            BLINKER_LOG("AliGenie Query Power State");
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
        default :
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.hswing(hsState ? "on" : "off");
            BlinkerAliGenie.vswing(vsState ? "on" : "off");
            BlinkerAliGenie.level(setLevel);
            BlinkerAliGenie.mode("quietWind");
            BlinkerAliGenie.temp(setTemp);
            BlinkerAliGenie.print();
            break;
    }
}

void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);

    Blinker.vibrate();
    
    uint32_t BlinkerTime = millis();
    
    Blinker.print("millis", BlinkerTime);
}

void setup()
{
    IrSender.begin();
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);

    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);

    Blinker.begin(auth, ssid, pswd);
    Blinker.attachData(dataRead);
    
    BlinkerAliGenie.attachPowerState(aligeniePowerState);
    BlinkerAliGenie.attachHSwing(aligenieHSwingState);
    BlinkerAliGenie.attachVSwing(aligenieVSwingState);
    BlinkerAliGenie.attachLevel(aligenieLevel);
    BlinkerAliGenie.attachMode(aligenieMode);
    BlinkerAliGenie.attachTemp(aligenieTemp);
    BlinkerAliGenie.attachRelativeTemp(aligenieRelativeTemp);
    BlinkerAliGenie.attachQuery(aligenieQuery);
}

void loop()
{
    Blinker.run();
}
#endif

#if 0
#include <Arduino.h>
#include <WiFi.h>
#include <PubSubClient.h>

#include "PinDefinitionsAndMore.h"       // Define macros for input and output pin etc.
#include <IRremote.hpp>


// WiFi
const char * ssid = "GimXR";           // Enter your WiFi name
const char * password = "jjyong666";    // Enter WiFi password

WiFiClient espClient;

void callback(char* topic, byte* payload, unsigned int length);

IPAddress server(43, 136, 130, 144);                            //要连接到的MQTT服务器IP
const int mqttPort =1883;                                       //要连接到的服务器端口号

PubSubClient client(server, mqttPort, callback, espClient);         //定义PubSubClient的实例

void MQTTConnect();

void setup()
{
    Serial.begin(115200);
    //MQTTConnect();
    IrSender.begin(); // Start with IR_SEND_PIN as send pin and if NO_LED_FEEDBACK_CODE is NOT defined, enable feedback LED at default feedback LED pin

    Serial.print(F("Ready to send IR signals at pin "));
    Serial.println(IR_SEND_PIN);
    pinMode(0, INPUT);
    //client.subscribe("AIR_CTRL");
}

void loop()
{
    uint32_t tRawData[]={0xC3, 0xA0, 0x3002000, 0x86};
    IrSender.sendPulseDistanceWidthFromArray(38, 9050, 4550, 600, 1700, 600, 550, &tRawData[0], 104, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, 0, 0);
    vTaskDelay(5000);
 
    //client.publish("tem", buf);                                                          //向MQTT服务器发送的信息(主题，内容)
    //IrSender.sendNEC(0x654C, 0x15, 1);
    //client.loop();                                                                         //保持监听防止超时
}

void MQTTConnect()
{
     WiFi.begin(ssid, password);
     while (WiFi.status() != WL_CONNECTED)                                                //等待连接wifi输出信息
     {
        delay(200);
        Serial.print(".");
     }
     Serial.println("WiFi connected!");
     Serial.print("ip is :");
     Serial.println(WiFi.localIP());

  while (!client.connected())                                                           //是否连接上MQTT服务器
  {
    if (client.connect("AIR_CTRL"))                                                     //如果服务器连接成功
    {
        Serial.println("MQTT Connected!");
    }
    else 
    {
        Serial.print(client.state());                                                 //重新连接函数
        delay(2000);                        
    }
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
    // In order to republish this payload, a copy must be made
    // as the orignal payload buffer will be overwritten whilst
    // constructing the PUBLISH packet.

    // Allocate the correct amount of memory for the payload copy
    byte * p = (byte*)malloc(length);
    // Copy the payload to the new buffer
    memcpy(p,payload,length);
    Serial.println((const char *)p);
    client.publish("outTopic", p, length);

    switch (p[0])
    {
    case  'U':
        printf("上\r\n");
        IrSender.sendNEC(0x654C, 0xB, 1);       //上
        break;
    case  'D':
        printf("下\r\n");
        IrSender.sendNEC(0x654C, 0xE, 1);       //下
        break;
    case  'L':
        printf("左\r\n");
        IrSender.sendNEC(0x654C, 0x10, 1);      //左
        break;
    case  'R':
        printf("右\r\n");
        IrSender.sendNEC(0x654C, 0x11, 1);      //右
        break;
    case  'P':
        printf("开机\r\n");
        IrSender.sendNEC(0x654C, 0xA, 1);       //开机
        break;
    case  'E':
        printf("确认\r\n");
        IrSender.sendNEC(0x654C, 0xD, 1);       //确认
        break;
    case  'M':
        printf("菜单\r\n");
        IrSender.sendNEC(0x654C, 0x37, 1);      //菜单
        break;
    case  'B':
        printf("返回\r\n");
        IrSender.sendNEC(0x654C, 0x1D, 1);      //返回
        break;
    case  '+':
        printf("音量+\r\n");
        IrSender.sendNEC(0x654C, 0x15, 1);      //音量+
        break;
    case  '-':
        printf("音量-\r\n");
        IrSender.sendNEC(0x654C, 0x1C, 1);      //音量-
        break;
    default:
        break;
    }
    // Free the memory
    free(p);
}
#endif

#if 1
/*
 * ReceiveDump.cpp
 *
 * Dumps the received signal in different flavors.
 * Since the printing takes so much time, repeat signals may be skipped or interpreted as UNKNOWN.
 *
 *  This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 ************************************************************************************
 * MIT License
 *
 * Copyright (c) 2020-2022 Armin Joachimsmeyer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 ************************************************************************************
 */
#include <Arduino.h>

#if !defined(RAW_BUFFER_LENGTH)
#define RAW_BUFFER_LENGTH  750  // 750 (600 if we have only 2k RAM) is the value for air condition remotes. Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
#endif

/*
 * You can change this value accordingly to the receiver module you use.
 * The required value can be derived from the timings printed here.
 * Keep in mind that the timings may change with the distance
 * between sender and receiver as well as with the ambient light intensity.
 */
#define MARK_EXCESS_MICROS    20 // recommended for the cheap VS1838 modules

#define RECORD_GAP_MICROS 50000 // Activate it for some LG air conditioner protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.

#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
#include <IRremote.hpp>

//+=============================================================================
// Configure the Arduino
//
void setup() {

    Serial.begin(115200);   // Status message will be sent to PC at 9600 baud
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));

    // Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
    IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);

    Serial.print(F("Ready to receive IR signals of protocols: "));
    printActiveIRProtocols(&Serial);
    Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));

    // infos for receive
    Serial.print(RECORD_GAP_MICROS);
    Serial.println(F(" us is the (minimum) gap, after which the start of a new IR packet is assumed"));
    Serial.print(MARK_EXCESS_MICROS);
    Serial.println(F(" us are subtracted from all marks and added to all spaces for decoding"));
}

//+=============================================================================
// The repeating section of the code
//
void loop() {
    if (IrReceiver.decode()) {  // Grab an IR code
        // Check if the buffer overflowed
        if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) {
            Serial.println(F("Overflow detected"));
            Serial.println(F("Try to increase the \"RAW_BUFFER_LENGTH\" value of " STR(RAW_BUFFER_LENGTH) " in " __FILE__));
            // see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library
        } else {
            Serial.println();                               // 2 blank lines between entries
            Serial.println();
            IrReceiver.printIRResultShort(&Serial);
            Serial.println();
            IrReceiver.printIRSendUsage(&Serial);
            Serial.println();
            Serial.println(F("Raw result in internal ticks (50 us) - with leading gap"));
            IrReceiver.printIRResultRawFormatted(&Serial, false); // Output the results in RAW format
            Serial.println(F("Raw result in microseconds - with leading gap"));
            IrReceiver.printIRResultRawFormatted(&Serial, true);  // Output the results in RAW format
            Serial.println();                               // blank line between entries
            Serial.print(F("Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS="));
            Serial.println(MARK_EXCESS_MICROS);
            IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); // Output the results as uint8_t source code array of ticks
            Serial.print(F("Result as microseconds array - compensated with MARK_EXCESS_MICROS="));
            Serial.println(MARK_EXCESS_MICROS);
            IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); // Output the results as uint16_t source code array of micros
            IrReceiver.printIRResultAsCVariables(&Serial);  // Output address and data as source code variables

            IrReceiver.compensateAndPrintIRResultAsPronto(&Serial);

            /*
             * Example for using the compensateAndStorePronto() function.
             * Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class.
             * The String object itself requires additional 440 bytes RAM from the heap.
             * This values are for an Arduino UNO.
             */
//        Serial.println();                                     // blank line between entries
//        String ProntoHEX = F("Pronto HEX contains: ");        // Assign string to ProtoHex string object
//        if (int size = IrReceiver.compensateAndStorePronto(&ProntoHEX)) {   // Dump the content of the IReceiver Pronto HEX to the String object
//            // Append compensateAndStorePronto() size information to the String object (requires 50 bytes heap)
//            ProntoHEX += F("\r\nProntoHEX is ");              // Add codes size information to the String object
//            ProntoHEX += size;
//            ProntoHEX += F(" characters long and contains "); // Add codes count information to the String object
//            ProntoHEX += size / 5;
//            ProntoHEX += F(" codes");
//            Serial.println(ProntoHEX.c_str());                // Print to the serial console the whole String object
//            Serial.println();                                 // blank line between entries
//        }
        }
        IrReceiver.resume();                            // Prepare for the next value
    }
}

#endif

#if 0
#include <Arduino.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.hpp>

//开机
const uint16_t rawData_1[199] = {4480,4420, 630,1620, 580,470, 630,1620, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1670, 530,1620, 580,520, 580,1670, 530,520, 630,470, 630,470, 630,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580,1670, 530,520, 580,520, 580,520, 580,520, 630,470, 630,470, 630,1620, 530,520, 630,470, 630,1620, 580,520, 580,470, 630,520, 580,1620, 580,520, 580,1620, 580,1620, 580,520, 580,1620, 580,1670, 530,1670, 530,5270, 4430,4470, 580,1620, 580,520, 580,1620, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1620, 580,1620, 580,520, 580,1620, 580,520, 580,520, 580,520, 580,1670, 530,1670, 530,1670, 580,1620, 580,1620, 580,1620, 530,1670, 530,1670, 530,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,1670, 530,520, 580,520, 580,1670, 530,520, 580,570, 530,520, 580,1670, 530,570, 530,1670, 530,1670, 530,570, 530,1670, 530,1670, 530,1670, 530};
//24 -> 25
const uint16_t rawData_2[199] = {4480,4420, 630,1620, 530,520, 630,1620, 530,1670, 580,470, 580,520, 630,1620, 530,520, 580,520, 580,1670, 580,470, 580,520, 580,1670, 530,1670, 530,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 530,1670, 530,1670, 580,1620, 580,1620, 530,1670, 530,1670, 530,1670, 530,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,1670, 530,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 580,1620, 530,520, 630,1620, 530,520, 580,1670, 530,1670, 530,1670, 530,5270, 4430,4470, 580,1620, 530,570, 580,1620, 530,1670, 530,520, 580,570, 530,1670, 530,520, 580,570, 580,1620, 530,520, 630,470, 630,1620, 530,1670, 580,470, 630,1620, 580,470, 580,520, 580,520, 630,1620, 530,1670, 580,1620, 530,1670, 530,1670, 580,1620, 530,1670, 580,1620, 530,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,1670, 530,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 530,1670, 530,520, 580,1670, 530,520, 630,1620, 530,1670, 530,1670, 530};
//25 -> 24
const uint16_t rawData_3[199] = {4430,4520, 530,1670, 530,520, 580,1670, 530,1670, 530,520, 580,520, 580,1670, 530,520, 580,520, 580,1670, 530,520, 580,520, 580,1620, 580,1670, 530,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,520, 580,520, 580,520, 580,520, 580,520, 580,1670, 530,520, 580,1670, 530,1620, 580,1620, 580,520, 580,520, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,520, 580,1670, 530,1670, 530,1620, 580,5270, 4380,4520, 530,1670, 530,520, 580,1670, 530,1670, 530,520, 580,520, 580,1670, 530,520, 580,520, 580,1670, 530,520, 580,520, 580,1670, 530,1670, 530,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,1670, 530,520, 580,520, 580,520, 580,520, 580,520, 580,1620, 580,520, 580,1620, 580,1620, 580,1670, 530,520, 580,520, 580,520, 580,520, 580,1670, 530,520, 580,520, 580,520, 580,1670, 530,1670, 530,1670, 530};
//关机
const uint16_t rawData_4[199] = {4480,4470, 580,1620, 580,520, 580,1620, 580,1620, 580,520, 580,520, 580,1670, 530,520, 580,520, 580,1670, 530,520, 580,520, 630,1620, 580,1620, 580,470, 630,1620, 580,520, 580,1620, 580,1670, 530,1670, 530,1670, 530,520, 630,1620, 580,1620, 580,1620, 580,520, 580,520, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1670, 530,1670, 580,1620, 580,470, 630,470, 630,470, 630,470, 630,520, 580,520, 580,520, 580,520, 580,1620, 580,1670, 530,1670, 530,1670, 580,1620, 580,5220, 4480,4420, 630,1620, 580,470, 630,1620, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1620, 580,520, 580,520, 580,1620, 580,1620, 580,520, 580,1620, 580,520, 580,1620, 580,1620, 580,1620, 580,1620, 580,520, 630,1570, 630,1570, 630,1570, 630,470, 630,470, 630,470, 630,470, 630,1570, 630,470, 630,470, 580,1620, 580,1620, 580,1620, 580,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,520, 580,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580};

void setup()
{
    IrSender.begin();

}

void loop()
{
    IrSender.sendRaw(rawData_1, 200, 38); // 记得换成你遥控器的红外线编码
    vTaskDelay(1000);
    IrSender.sendRaw(rawData_2, 200, 38); // 记得换成你遥控器的红外线编码
    vTaskDelay(1000);
    IrSender.sendRaw(rawData_3, 200, 38); // 记得换成你遥控器的红外线编码
    vTaskDelay(1000);
    IrSender.sendRaw(rawData_4, 200, 38); // 记得换成你遥控器的红外线编码
    vTaskDelay(1000);
}

#endif